﻿namespace WFBot.Framework.Web.Bootstrappers
{
    using System;
    using System.Web.Mvc;
    using System.Web.Routing;
    using MvcExtensions;

    public class ConfigureRoutes : RegisterRoutesBase
    {
        protected override void Register(RouteCollection routes)
        {
            Func<IRouteConstraint> idConstraint = () => new PositiveLongConstraint();

            routes.Clear();

            // Turns off the unnecessary file exists check
            routes.RouteExistingFiles = true;

            // Ignore axd files
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // Ignore known static files

            // Ignore the assets directory which contains css, images and js
            routes.IgnoreRoute("Content/{*pathInfo}");
            routes.IgnoreRoute("Scripts/{*pathInfo}");
            routes.IgnoreRoute("WebCallr/{*pathInfo}");

            routes.IgnoreRoute("{*favicon}", new { favicon = new RegexConstraint(@"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?") });

            routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Bot", action = "Index", id = string.Empty }, idConstraint());
        }
    }
}
